from typing import List  # noqa: D100

from ..api.db_operator import DBOperator
from ..api.git_reader import GitReader


class RepositoryService:
    """负责处理仓库信息，与 AccountService 类似."""

    def __init__(self, git_reader: GitReader, db_operator: DBOperator):
        self.git_reader = git_reader
        self.db_operator = db_operator

    def start_import_repositories(self):
        """启动仓库导入流程."""
        repositories = []
        page = 1
        while True:
            data = self.git_reader.get_projects_from_gitlab(page=page)
            if len(data) == 0:
                break
            repositories.extend(data)
            page += 1
        print(f"Fetched {len(repositories)} repositories.")
        self.db_operator.insert_repositories(repositories)

    # 其他方法根据需要
